'use strict';
var enums = require('../shared/enums.js');

module.exports = function(sequelize, DataTypes) {
  var autonym = sequelize.define('autonym', {
    id: {
      type: DataTypes.UUID,
      primaryKey: true,
      defaultValue: DataTypes.UUIDV1
    },
    realname: {
      type: DataTypes.STRING(13),
      allowNull: false,
      validate: {
        notEmpty: true
      }
    },
    idCardNo: {
      type: DataTypes.STRING(18),
      allowNull: false,
      validate: {
        notEmpty: true
      }
    },
    idCardFront: {
      type: DataTypes.STRING,
      allowNull: false
    },
    idCardBack: {
      type: DataTypes.STRING,
      allowNull: false
    },
    validateStatus: {
      type: DataTypes.ENUM(enums.validateStatus),
      allowNull: false,
      defaultValue: 'pending',
      validate: {
        isIn: [enums.validateStatus]
      }
    }
  }, {
    classMethods: {
      associate: function(models) {
      }
    }
  });
  return autonym;
};
